package com.wy.myapplication;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


    private String TAG = "MainActivity";

    private MyProgressBar myProgressBar;
    private _58Animation _58Animation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        myProgressBar = findViewById(R.id.myProgressBar);
        _58Animation = findViewById(R.id._58Animation);

        ValueAnimator valueAnimator = ObjectAnimator.ofInt(0, 100);
        valueAnimator.setDuration(5 * 1000);
        valueAnimator.setInterpolator(new DecelerateInterpolator());
        valueAnimator.start();
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int result = (int) animation.getAnimatedValue();
                myProgressBar.setmProgress(result);
            }
        });

        ValueAnimator valueAnimator1 = ObjectAnimator.ofInt(1, 4);
        valueAnimator1.setDuration(2 * 1000);
        valueAnimator1.setRepeatCount(100);
        valueAnimator1.setInterpolator(new LinearInterpolator());
        valueAnimator1.start();
        valueAnimator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int animatedValue = (int) animation.getAnimatedValue();
                Log.i(TAG, "animatedValue:" + animatedValue);
                _58Animation.setmType(animatedValue);
            }
        });

    }

}